package com.zz.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zz.entity.ConsumeLogs;
import com.zz.entity.ConsumeLogsSearch;
import com.zz.entity.GetStatistics;
import com.zz.service.ConsumeLogsService;

@Controller
@RequestMapping("consumelogs")
public class ConsumeLogsController {
	@Autowired
	ConsumeLogsService cService;
	
	/**
	 * 测试查询
	 */
	@RequestMapping("getAll1")
	@ResponseBody
	public List<ConsumeLogs> getAll1(){
		List<ConsumeLogs> clist = cService.GetAll1();
		return clist;
	}
	/**
	 * 测试分页查询
	 */
	@RequestMapping("getAll2")
	@ResponseBody
	public Page<ConsumeLogs> getAll2(ConsumeLogsSearch consearch,Integer page,Integer limit){
		return cService.GetAll2(consearch, page, limit);
	}
	/**
	 * 多条件分页查询
	 */
	@RequestMapping("getAll")
	@ResponseBody
	public Map<String, Object> getAll(ConsumeLogsSearch consearch,Integer page,Integer limit){
		return cService.GetAll(consearch, page-1, limit);
	}
	
	/**
	 * 打卡添加浏览数据
	 */
	@RequestMapping("saveAndFlush")
	@ResponseBody
	public Integer saveAndFlush(ConsumeLogs con){
		return cService.SaveAndFlush(con);
	}
	
	/**
	 * 查询各科室当天使用人数
	 */
	@RequestMapping("getPeopleCount")
	@ResponseBody
	public List<GetStatistics> getPeopleCount(String indate,String outdate){
		indate = "'"+indate+"'";
		outdate = "'"+outdate+"'";
		List<GetStatistics> glist = cService.TimingConsumeLogs(indate, outdate);
		System.out.println(glist);
		return glist;
	}
	
}
